---
layout: "default"
title: "AnyRandomAccessIndex"
description: "Swift documentation for 'AnyRandomAccessIndex': A wrapper over an underlying RandomAccessIndexType that hides
the specific underlying type."
keywords: "AnyRandomAccessIndex,struct,swift,documentation,advancedBy,advancedBy,distanceTo,predecessor,stride,stride,successor,Distance"
root: "/v2.0"
---

<div class="intro-declaration"><code class="language-swift">struct AnyRandomAccessIndex</code></div>

<div class="discussion comment">
    <p>A wrapper over an underlying <code>RandomAccessIndexType</code> that hides
the specific underlying type.</p>

<p><strong>See Also:</strong> <code>AnyRandomAccessCollection</code></p>
</div>

<table class="standard">
<tr>
<th id="inheritance">Inheritance</th>
<td>
<code class="inherits">BidirectionalIndexType, Comparable, Equatable, ForwardIndexType, RandomAccessIndexType, Strideable, _Incrementable, _RandomAccessAmbiguity, _Strideable</code>
<span class="viz"><a href="hierarchy/">View Protocol Hierarchy &rarr;</a></span>
</td>
</tr>

<tr>
<th id="aliases">Associated Types</th>
<td>
<span id="aliasesmark"></span>
<div class="declaration">
<code class="language-swift">Distance = IntMax</code>
</div>
</td>
</tr>


<tr>
<th>Import</th>
<td><code class="language-swift">import Swift</code></td>
</tr>

</table>


<h3>Initializers</h3>
<div class="declaration" id="init_">
<a class="toggle-link" data-toggle="collapse" href="#comment-init_">init(<wbr>_:)</a><div class="comment collapse" id="comment-init_"><div class="p">
    <p>Wrap and forward operations to <code>base</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">init&lt;BaseIndex : RandomAccessIndexType&gt;(_ base: BaseIndex)</code>

    </div></div>
</div>





<h3>Instance Methods</h3>
<div class="declaration" id="func-advancedby_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-advancedby_">func advancedBy(<wbr>_:)</a>
        
<div class="comment collapse" id="comment-func-advancedby_"><div class="p">
    

    <h4>Declaration</h4>    
    <code class="language-swift">func advancedBy(amount: Distance) -&gt; AnyRandomAccessIndex</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/AnyRandomAccessIndex/"><code>AnyRandomAccessIndex</code></a>,    <a href="../../protocol/BidirectionalIndexType/"><code>BidirectionalIndexType</code></a>,    <a href="../../protocol/_RandomAccessAmbiguity/"><code>_RandomAccessAmbiguity</code></a>,    <a href="../../protocol/ForwardIndexType/"><code>ForwardIndexType</code></a>    
</div></div>
</div>
<div class="declaration" id="func-advancedby_limit_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-advancedby_limit_">func advancedBy(<wbr>_:<wbr>limit:)</a>
        
<div class="comment collapse" id="comment-func-advancedby_limit_"><div class="p">
    

    <h4>Declaration</h4>    
    <code class="language-swift">func advancedBy(amount: Distance, limit: AnyRandomAccessIndex) -&gt; AnyRandomAccessIndex</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/AnyRandomAccessIndex/"><code>AnyRandomAccessIndex</code></a>,    <a href="../../protocol/RandomAccessIndexType/"><code>RandomAccessIndexType</code></a>,    <a href="../../protocol/BidirectionalIndexType/"><code>BidirectionalIndexType</code></a>,    <a href="../../protocol/ForwardIndexType/"><code>ForwardIndexType</code></a>    
</div></div>
</div>
<div class="declaration" id="func-distanceto_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-distanceto_">func distanceTo(<wbr>_:)</a>
        
<div class="comment collapse" id="comment-func-distanceto_"><div class="p">
    

    <h4>Declaration</h4>    
    <code class="language-swift">func distanceTo(other: AnyRandomAccessIndex) -&gt; Distance</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/AnyRandomAccessIndex/"><code>AnyRandomAccessIndex</code></a>,    <a href="../../protocol/ForwardIndexType/"><code>ForwardIndexType</code></a>    
</div></div>
</div>
<div class="declaration" id="func-predecessor">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-predecessor">func predecessor()</a>
        
<div class="comment collapse" id="comment-func-predecessor"><div class="p">
    <p>Return the previous consecutive value in a discrete sequence of
<code>AnyRandomAccessIndex</code> values.</p>

<p><strong>Requires:</strong> <code>self</code> has a well-defined predecessor.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func predecessor() -&gt; AnyRandomAccessIndex</code>
    
    
</div></div>
</div>
<div class="declaration inherited" id="func-stride-through_by_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-stride-through_by_">func stride(<wbr>through:<wbr>by:)</a>
        
<div class="comment collapse" id="comment-func-stride-through_by_"><div class="p">
    <p>Return the sequence of values (<code>start</code>, <code>start + stride</code>, <code>start +
stride + stride</code>, ... <em>last</em>) where <em>last</em> is the last value in
the progression less than or equal to <code>end</code>.</p>

<p><strong>Note:</strong> There is no guarantee that <code>end</code> is an element of the sequence.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func stride(through end: AnyRandomAccessIndex, by stride: AnyRandomAccessIndex.Stride) -&gt; StrideThrough&lt;AnyRandomAccessIndex&gt;</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/Strideable/"><code>Strideable</code></a>    
</div></div>
</div>
<div class="declaration inherited" id="func-stride-to_by_">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-stride-to_by_">func stride(<wbr>to:<wbr>by:)</a>
        
<div class="comment collapse" id="comment-func-stride-to_by_"><div class="p">
    <p>Return the sequence of values (<code>self</code>, <code>self + stride</code>, <code>self +
stride + stride</code>, ... <em>last</em>) where <em>last</em> is the last value in
the progression that is less than <code>end</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func stride(to end: AnyRandomAccessIndex, by stride: AnyRandomAccessIndex.Stride) -&gt; StrideTo&lt;AnyRandomAccessIndex&gt;</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/Strideable/"><code>Strideable</code></a>    
</div></div>
</div>
<div class="declaration" id="func-successor">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-successor">func successor()</a>
        
<div class="comment collapse" id="comment-func-successor"><div class="p">
    <p>Return the next consecutive value in a discrete sequence of
<code>AnyRandomAccessIndex</code> values.</p>

<p><strong>Requires:</strong> <code>self</code> has a well-defined successor.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func successor() -&gt; AnyRandomAccessIndex</code>
    
    
</div></div>
</div>


